home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / slip_new.zip / PKTCHK.ASM < prev    next >
Assembly Source File  |  1992-09-25  |  3KB  |  149 lines

  1. version    equ    1
  2.  
  3. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  4. ;  Modified TERMIN.ASM to be PKTCHK.ASM return errorlevel, don't terminate
  5. ;    07/24/89 Glen Marianko, Albert Einstein College of Medicine
  6.  
  7. ;   This program is free software; you can redistribute it and/or modify
  8. ;   it under the terms of the GNU General Public License as published by
  9. ;   the Free Software Foundation, version 1.
  10. ;
  11. ;   This program is distributed in the hope that it will be useful,
  12. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;   GNU General Public License for more details.
  15. ;
  16. ;   You should have received a copy of the GNU General Public License
  17. ;   along with this program; if not, write to the Free Software
  18. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.     include    defs.asm
  21.  
  22. code    segment word public
  23.     assume    cs:code, ds:code
  24.  
  25.     org    80h
  26. phd_dioa    label    byte
  27.  
  28.     org    100h
  29. start:
  30.     jmp    start_1
  31.  
  32. copyleft_msg    label    byte
  33.  db "Packet checker version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version," copyright 1990, Russell Nelson.",CR,LF
  34.  db "This program is free software; see the file COPYING for details.",CR,LF
  35.  db "NO WARRANTY; see the file COPYING for details.",CR,LF
  36.  
  37. their_isr    dd    ?
  38. entry_point    db    0,?,?,?
  39. packet_int_end  db    0,?,?,?
  40. signature    db    'PKT DRVR',0
  41. signature_len    equ    $-signature
  42. got_int        db    0
  43. no_signature_msg    db    "Packet driver not found.",CR,LF,'$'
  44. signature_msg    db    "Packet driver found at ",'$'
  45. no_signatures_msg    db    "No packet driver found in specified range.",CR,LF,'$'
  46. usage_msg    db    "usage: pktchk <packet_int_no> [<packet_int_no_end>]",CR,LF,'$'
  47.  
  48. usage_error:
  49.     mov    dx,offset usage_msg
  50. error:
  51.     mov    ah,9
  52.     int    21h
  53. err_quit:
  54.     mov    al,1
  55.         mov     ah,04ch                 ; exit with errorlevel 1
  56.         int     21h
  57.  
  58. start_1:
  59.     mov    si,offset phd_dioa+1
  60.     call    skip_blanks
  61.     cmp    al,CR            ;end of line?
  62.     je    usage_error
  63.  
  64.     mov    di,offset entry_point
  65.     call    get_number
  66.     cmp    entry_point+1,0
  67.     jne    usage_error
  68.  
  69.     mov    di,offset packet_int_end
  70.     call    get_number
  71.     cmp    packet_int_end+1,0
  72.     jne    usage_error
  73.     mov    di,si
  74.     call    skip_blanks
  75.     cmp    al,CR            ;end of line?
  76.     jne    usage_error
  77.  
  78.     cmp    packet_int_end,0
  79.     jne    chk_range        ; second arg specified
  80.  
  81.     call    chk_int
  82.     jne    no_signature_err
  83.     call    pkt_found
  84. all_done:
  85.     mov    al,0
  86.     mov    ah,04ch
  87.     int    21h            ; exit with errorlevel 0
  88.  
  89. no_signature_err:
  90.     mov    dx,offset no_signature_msg
  91.     jmp    error
  92.  
  93. chk_range:
  94.     mov    al,packet_int_end
  95.     sub    al,entry_point
  96.     jc    usage_error
  97.  
  98. chk_loop:
  99.     call    chk_int
  100.     jne    chk_none
  101.     call    pkt_found
  102.     inc    got_int            ; flag we got one
  103. chk_none:
  104.     mov    al,entry_point
  105.     cmp    packet_int_end,al
  106.     jz    no_signatures_chk
  107.     inc    entry_point        ; increment
  108.     jmp    chk_loop
  109.  
  110. no_signatures_chk:
  111.     cmp    got_int,0
  112.     jnz    all_done
  113.  
  114. no_signatures:
  115.     mov    dx,offset no_signatures_msg
  116.     jmp    error
  117.  
  118.     public    chk_int
  119. chk_int:
  120.     mov    ah,35h            ;get their packet interrupt.
  121.     mov    al,entry_point
  122.     int    21h
  123.     mov    their_isr.offs,bx
  124.     mov    their_isr.segm,es
  125.     lea    di,3[bx]
  126.     mov    si,offset signature
  127.     mov    cx,signature_len
  128.     repe    cmpsb
  129.     ret
  130.  
  131.     public    pkt_found
  132. pkt_found:
  133.     mov    dx,offset signature_msg
  134.     mov    di,offset entry_point
  135.     jmp    print_number
  136.  
  137.     include    getnum.asm
  138.     include    skipblk.asm
  139.     include    getdig.asm
  140.     include    decout.asm
  141.     include    digout.asm
  142.     include    chrout.asm
  143.     include    printnum.asm
  144.     include    crlf.asm
  145.  
  146. code    ends
  147.  
  148.     end    start
  149.